home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
begincpp
/
#7_ver1.cpp
< prev
next >
Wrap
Text File
|
1990-08-03
|
565b
|
29 lines
void *malloc(unsigned);
int free (void *);
struct tag_name { //tag_name is also a type in C++
int i;
float f;
};
class class_one {
tag_name t; //implicitly declare class_one *this;
public:
class_one (int i0 = 0, float f0 = 0) { t.i = i0, t.f = f0; }
class_one *tag() { return this; }
};
class class_two {
public:
class_two (unsigned size) { this = (class_two *) malloc (size); }
~class_two() { free (this); this = 0; }
};
main()
{
class_one c1 (1, 1.1), cc1;
class_two c2 (sizeof(class_two)) ;
cc1 = *c1.tag();
}